In [1]:
%load_ext load_style
%load_style talk.css
In this notebook, we will do a little complicated operations
Data
wind data can be downlaed from https://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanalysis2.html
This u-wind is a 4D data, includding [months|levels|lat|lon]. The presure levels in hPa.
Moreover, the wind data with scaling and offset. when using them, have to restore them to oringal values.
In [2]:
% matplotlib inline
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap # plot on map projections
from netCDF4 import Dataset as netcdf # netcdf4-python module
In [3]:
ncset = netcdf(r'data/uwnd3.mon.mean.nc')
print(ncset)
In [4]:
ncset.set_auto_mask(False)
lon = ncset['lon'][:]
lat = ncset['lat'][:]
lev = ncset['level'][:]
u = ncset['uwnd'][504:624,:] # for the period 1990-1999.
print(u.shape)
In [5]:
print(lev)
In [6]:
plot(u[:,1,0, 0])
Out[6]:
In [7]:
u_10y = np.mean(u, axis=0) # calculate mean for all years and months
u_10y.shape
Out[7]:
In [8]:
u_10y_std=np.std(u, axis=0)
u_10y.shape
Out[8]:
In [9]:
[lons, lats] = meshgrid(lon,lat)
m = Basemap(projection='robin', lon_0=0)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
m.drawmapboundary(fill_color='aqua')
minu = floor(np.min(u_10y[0]))
maxu = ceil(np.max(u_10y[0]))
h = m.pcolormesh(lons, lats, u_10y[0], shading='flat',latlon=True, cmap='jet', vmin=minu, vmax=maxu)
m.colorbar(h, location='bottom', pad="15%", label='[$^oC$]')
plt.title('U1000 Mean between 1990-1999 [m/s]')
Out[9]:
In [10]:
[lons, lats] = meshgrid(lon,lat)
m = Basemap(projection='robin', lon_0=0)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
m.drawmapboundary(fill_color='aqua')
minu = floor(np.min(u_10y_std[0]))
maxu = ceil(np.max(u_10y_std[0]))
h = m.pcolormesh(lons, lats, u_10y_std[0], shading='flat',latlon=True, cmap='jet', vmin=minu, vmax=maxu)
m.colorbar(h, location='bottom', pad="15%", label='[$^oC$]')
plt.title('U1000 STD between 1990-1999 [m/s]')
Out[10]:
http://unidata.github.io/netcdf4-python/
John D. Hunter. Matplotlib: A 2D Graphics Environment, Computing in Science & Engineering, 9, 90-95 (2007), DOI:10.1109/MCSE.2007.55
Stéfan van der Walt, S. Chris Colbert and Gaël Varoquaux. The NumPy Array: A Structure for Efficient Numerical Computation, Computing in Science & Engineering, 13, 22-30 (2011), DOI:10.1109/MCSE.2011.37
Kalnay et al.,The NCEP/NCAR 40-year reanalysis project, Bull. Amer. Meteor. Soc., 77, 437-470, 1996.
In [ ]: